#include "apfsds_config.h"


static tstack_t apdstinfo_tlsstk;
static TLS_INITIAL apdstls_t *apdstinfo_tls;
DEF_APDSTINFO_TLS(&apdstinfo_tlsstk, &apdstinfo_tls, malloc, APFSDS_COREID_UPDFREQ, mp_coreid)
static TLS_INITIAL spobj_t *lknode_tls;
DEF_LOCKNODE_SPSLAB(splknode, &lknode_tls, HDEF_CACHE_LINE_BYTES, SPLK_POOL_SIZE)


// DEF_NLOCK(mcs, mcs, OUFUN_OF(spin_wait), OUFUN_OF(spslablknode))
// DEF_NLOCK(mcs, bounded_mcs, OUFUN_OF(spin_wait_bounded), OUFUN_OF(spslablknode))
// DEF_NLOCK(mcs, futex_mcs, OUFUN_OF(futex_wait), OUFUN_OF(spslablknode))
// DEF_NLOCK(mcs, yield_mcs, OUFUN_OF(schedyield_wait), OUFUN_OF(spslablknode))


/* 先定义 hsync */
/* DEF_HSYNC_STATE(hsync_state, APDS_NUMA_NR, spin)
DEF_HSYNC(hsync, APDS_NUMA_NR, APDS_GET_NUMANODES, spin, &hsync_state.hsync_glk, OUFUN_OF(hsync_state))
DEF_COMBINE(hsync, hsync, OUFUN_OF(apdstls), OUFUN_OF(spinyield_wait), OUFUN_OF(spslablknode)) */
DEF_HSYNC(hsync, APDS_NUMA_NR, APDS_GET_NUMANODES, spin)
DEF_COMBINE(hsync, hsync, OUFUN_OF(apdstls), OUFUN_OF(spinyield_wait), OUFUN_OF(spslablknode))
/* DEF_COMBINE(hsync, hsync, OUFUN_OF(apdstls), OUFUN_OF(spin_wait), OUFUN_OF(spslablknode)) */

APDS2APFSDS(hsync, (OUFUN_OF(alignlknode))->get_lknode,  (OUFUN_OF(alignlknode))->ret_lknode)

/* 初始化 */
#include <pthreadalt/pthreadalt_init.h>
DEF_PTHREADALT_INIT
DEF_SYSINIT(apdstls)
DEF_CFLOWINIT(apdstls)
DEF_CFLOWFIN(apdstls, splknode)
DEF_SYSFIN(__omega)
